package com.gxljc.bear.crawler.cli;

import org.apache.commons.cli.CommandLine;
import org.apache.commons.cli.Options;
import org.apache.log4j.Logger;

import com.gxljc.commons.quartz.QuartzExecutor;
import com.gxljc.commons.quartz.QuartzJobUtils;
import com.gxljc.commons.util.AdvCli;
import com.gxljc.commons.util.CliRunner;
import com.gxljc.bear.crawler.itaogao.NewsBaseCrawler;
import com.gxljc.bear.crawler.itaogao.bjbusiness.BJBusinessDetailCrawler;
import com.gxljc.bear.crawler.itaogao.business21.Business21Crawler;
import com.gxljc.bear.crawler.itaogao.caijing.CJMagazineDetailCrawler;
import com.gxljc.bear.crawler.itaogao.caijing.CJYuanChuangDetailCrawler;
import com.gxljc.bear.crawler.itaogao.cbcomcn.CbcomcnPageCrawler;
import com.gxljc.bear.crawler.itaogao.cbcomcn.CbcomcnSeedCrawler;
import com.gxljc.bear.crawler.itaogao.cbcomcn.CbcomcnUpdateCrawler;
import com.gxljc.bear.crawler.itaogao.ccstock.CcstockDetailCrawler;
import com.gxljc.bear.crawler.itaogao.chinanews.ChinanewsCrawler;
import com.gxljc.bear.crawler.itaogao.cnfol.CnfolPageCrawler;
import com.gxljc.bear.crawler.itaogao.cnfol.CnfolSeedCrawler;
import com.gxljc.bear.crawler.itaogao.cnfol.CnfolUpdateCrawler;
import com.gxljc.bear.crawler.itaogao.cnstock.CnstockPageCrawler;
import com.gxljc.bear.crawler.itaogao.cnstock.CnstockSeedCrawler;
import com.gxljc.bear.crawler.itaogao.cnstock.CnstockUpdateCrawler;
import com.gxljc.bear.crawler.itaogao.cscomcn.CscomcnPageCrawler;
import com.gxljc.bear.crawler.itaogao.cscomcn.CscomcnSeedCrawler;
import com.gxljc.bear.crawler.itaogao.cscomcn.CscomcnUpdateCrawler;
import com.gxljc.bear.crawler.itaogao.guochengxin.GuochengxinPageCrawler;
import com.gxljc.bear.crawler.itaogao.guochengxin.GuochengxinSeedCrawler;
import com.gxljc.bear.crawler.itaogao.guochengxin.GuochengxinUpdateCrawler;
import com.gxljc.bear.crawler.itaogao.gzdaily.GzDailyPageCrawler;
import com.gxljc.bear.crawler.itaogao.gzdaily.GzDailySeedCrawler;
import com.gxljc.bear.crawler.itaogao.gzdaily.GzDailyUpdateCrawler;
import com.gxljc.bear.crawler.itaogao.huanqiu.HuanqiuCrawlerAlternative;
import com.gxljc.bear.crawler.itaogao.infzm.InfzmPageCrawler;
import com.gxljc.bear.crawler.itaogao.infzm.InfzmSeedCrawler;
import com.gxljc.bear.crawler.itaogao.infzm.InfzmUpdateCrawler;
import com.gxljc.bear.crawler.itaogao.jingji21.Jingji21PageCrawler;
import com.gxljc.bear.crawler.itaogao.jingji21.Jingji21SeedCrawler;
import com.gxljc.bear.crawler.itaogao.jingji21.Jingji21UpdateCrawler;
import com.gxljc.bear.crawler.itaogao.jjckb.JjckbDetailCrawler;
import com.gxljc.bear.crawler.itaogao.jjrb.JjrbDetailCrawler;
import com.gxljc.bear.crawler.itaogao.mrjjxw.MrjjxwCrawler;
import com.gxljc.bear.crawler.itaogao.oeeee.OeeeePageCrawler;
import com.gxljc.bear.crawler.itaogao.oeeee.OeeeeSeedCrawler;
import com.gxljc.bear.crawler.itaogao.oeeee.OeeeeSeedTagCrawler;
import com.gxljc.bear.crawler.itaogao.oeeee.OeeeeUpdateCrawler;
import com.gxljc.bear.crawler.itaogao.southcn.SouthcnPageCrawler;
import com.gxljc.bear.crawler.itaogao.southcn.SouthcnSeedCrawler;
import com.gxljc.bear.crawler.itaogao.southcn.SouthcnUpdateCrawler;
import com.gxljc.bear.crawler.itaogao.stcn.STCNDetailCrawler;
import com.gxljc.bear.crawler.itaogao.szsb.SzsbDetailCrawler;
import com.gxljc.bear.crawler.itaogao.tmtpost.TmtpostCrawler;
import com.gxljc.bear.crawler.itaogao.yangcheng.YangchengEveningNewsCrawler;
import com.gxljc.bear.crawler.itaogao.yicai.YiCaiDetailCrawler;
import com.gxljc.bear.crawler.itaogao.yinhang123.Yinhang123PageCrawler;
import com.gxljc.bear.crawler.itaogao.yinhang123.Yinhang123SeedCrawler;
import com.gxljc.bear.crawler.itaogao.yinhang123.Yinhang123UpdateCrawler;
import com.gxljc.bear.crawler.itaogao.ynxxb.YnxxbDetailCrawler;
import com.gxljc.bear.crawler.proxy.ProxyUtil;

/**
 * 爱淘稿爬虫.
 */
public class ItaogaoCrawlerCli implements QuartzExecutor , CliRunner {




	public static final Logger LOG = Logger.getLogger(ItaogaoCrawlerCli.class);

	// 每2点30分触发
	private static final String CRON_EXP_JINGJI21 = "0 30 7,8,9,21 * * ?"; // 21世纪经济报道每天更新2次
	private static final String CRON_EXP_GZDIALY = "0 30 7,21 * * ?"; // 广州日报每天更新2次
	private static final String CRON_EXP_JJCKB = "0 30 7,21 * * ?"; // 经济参考报每天更新2次
	private static final String CRON_EXP_MRJJXW = "0 30 7,21 * * ?"; // 每日经济新闻每天更新2次
	private static final String CRON_EXP_STCN = "0 30 7,8,21 * * ?"; // 证券时报每天更新2次
	private static final String CRON_EXP_CNSTOCK = "0 50 7,21 * * ?"; // 上海证券报每天更新2次
	private static final String CRON_EXP_CCSTOCK = "0 50 7,21 * * ?"; // 证券日报每天更新2次
	private static final String CRON_EXP_INFZM = "0 0 5,10,15,20 * * ?"; // 南方周末每天更新4次
	private static final String CRON_EXP_SOUTHCN = "0 50 7,8,9,21 * * ?"; // 南方日报每天更新4次
	private static final String CRON_EXP_OEEEE = "0 10 8,22 * * ?"; // 南方都市报每天更新2次
	private static final String CRON_EXP_CECN = "0 10 8,22 * * ?"; // 经济日报每天更新2次
	private static final String CRON_EXP_CSCOMCN = "0 10 * * * ?"; // 中国证券报每小时更新1次
	private static final String CRON_EXP_YCWB = "0 10 8,22 * * ?"; // 羊城晚报每天更新2次
	private static final String CRON_EXP_SZNEWS = "0 30 8,22 * * ?"; // 深圳商报每天更新2次
	private static final String CRON_EXP_YNXXB = "0 30 8,22 * * ?"; // 云南信息报每天更新2次
	private static final String CRON_EXP_BJBUSINESS = "0 30 8,22 * * ?"; // 北京商报每天更新2次
	private static final String CRON_EXP_CAIJING = "0 30 10,23 ? * 2"; // 《财经》杂志7天1次
	private static final String CRON_EXP_4TIMES = "0 0 5,10,15,20 * * ?"; // 网站类每天更新4次
	private static final String CRON_EXP_1TIME = "0 0 8,21 * * ?"; // 网站类每天更新2次
	private static final String CRON_EXP_BUSINESS21 = "0 30 1 1,15 * ?";// 每个月第一天1:30触发
	private static final String CRON_EXP_CBCOMCN = "0 30 8 ? * 2,3,4";// 周1，2，3触发

	// type of running [all|page]
	private String site;
	private String type;
	private String time = "";
	private boolean proxy = false;

	@Override
	public Options initOptions() {
		Options options = new Options();
		options.addOption(AdvCli.CLI_PARAM_HELP, false, "ItaogaoCrawlerCli print help message");
		// run periodically
		options.addOption("quartz", false, "run in quartz mode");
		options.addOption("once", false, "run in once mode");
		options.addOption("proxy", false, "run in proxy mode");
		options.addOption(
				"site",
				true,
				"jingji21|gzdialy|jjckb|mrjjxw|stcn|cnstock|ccstock|cbcomcn|infzm|southcn|oeeee|cecn|cscomcn|yicai|ycwb|sznews|ynxxb|business21|bjbusiness|magazinecaijing|tmtpost|chinanews|huanqiu|caijing");
		options.addOption("type", true, "tag|pagesize|seed|all|update");
		options.addOption("time", true, "2016-11-01");
		return options;
	}

	@Override
	public boolean validateOptions(CommandLine cmdLine) {
		return true;
	}

	@Override
	public void start(CommandLine cmdLine) {
		// if there is no type parameter, do not run the program
		if (cmdLine.hasOption("site")) {
			site = cmdLine.getOptionValue("site");
		} else {
			System.out.println("site parameter is compulsory.");
			return;
		}
		if (cmdLine.hasOption("type")) {
			type = cmdLine.getOptionValue("type");
		} else {
			System.out.println("type parameter is compulsory.");
			return;
		}
		if (cmdLine.hasOption("proxy")) {
			proxy = true;
		}

		if (cmdLine.hasOption("time")) {
			time = cmdLine.getOptionValue("time");
		} else {
			System.out.println("time parameter is compulsory.");
			// return;
		}

		if (cmdLine.hasOption("quartz")) {
			try {
				LOG.info("Create Quartz Job of Itaogao Crawler.");
				if ("jingji21".equals(site)) {
					QuartzJobUtils.createQuartzJob(CRON_EXP_JINGJI21, "ItaogaoCrawlerCli", this);
				} else if ("gzdialy".equals(site)) {
					QuartzJobUtils.createQuartzJob(CRON_EXP_GZDIALY, "ItaogaoCrawlerCli", this);
				} else if ("jjckb".equals(site)) {
					QuartzJobUtils.createQuartzJob(CRON_EXP_JJCKB, "ItaogaoCrawlerCli", this);
				} else if ("mrjjxw".equals(site)) {
					QuartzJobUtils.createQuartzJob(CRON_EXP_MRJJXW, "ItaogaoCrawlerCli", this);
				} else if ("stcn".equals(site)) {
					QuartzJobUtils.createQuartzJob(CRON_EXP_STCN, "ItaogaoCrawlerCli", this);
				} else if ("cnstock".equals(site)) {
					QuartzJobUtils.createQuartzJob(CRON_EXP_CNSTOCK, "ItaogaoCrawlerCli", this);
				} else if ("ccstock".equals(site)) {
					QuartzJobUtils.createQuartzJob(CRON_EXP_CCSTOCK, "ItaogaoCrawlerCli", this);
				} else if ("infzm".equals(site)) {
					QuartzJobUtils.createQuartzJob(CRON_EXP_INFZM, "ItaogaoCrawlerCli", this);
				} else if ("southcn".equals(site)) {
					QuartzJobUtils.createQuartzJob(CRON_EXP_SOUTHCN, "ItaogaoCrawlerCli", this);
				} else if ("oeeee".equals(site)) {
					QuartzJobUtils.createQuartzJob(CRON_EXP_OEEEE, "ItaogaoCrawlerCli", this);
				} else if ("cecn".equals(site)) {
					QuartzJobUtils.createQuartzJob(CRON_EXP_CECN, "ItaogaoCrawlerCli", this);
				} else if ("cscomcn".equals(site)) {
					QuartzJobUtils.createQuartzJob(CRON_EXP_CSCOMCN, "ItaogaoCrawlerCli", this);
				} else if ("cbcomcn".equals(site)) {
					QuartzJobUtils.createQuartzJob(CRON_EXP_CBCOMCN, "ItaogaoCrawlerCli", this);
				} else if ("yicai".equals(site)) {
					QuartzJobUtils.createQuartzJob(CRON_EXP_4TIMES, "ItaogaoCrawlerCli", this);
				} else if ("ycwb".equals(site)) {
					QuartzJobUtils.createQuartzJob(CRON_EXP_YCWB, "ItaogaoCrawlerCli", this);
				} else if ("szsb".equals(site)) {
					QuartzJobUtils.createQuartzJob(CRON_EXP_SZNEWS, "ItaogaoCrawlerCli", this);
				} else if ("ynxxb".equals(site)) {
					QuartzJobUtils.createQuartzJob(CRON_EXP_YNXXB, "ItaogaoCrawlerCli", this);
				} else if ("business21".equals(site)) {
					QuartzJobUtils.createQuartzJob(CRON_EXP_BUSINESS21, "ItaogaoCrawlerCli", this);
				} else if ("bjbusiness".equals(site)) {
					QuartzJobUtils.createQuartzJob(CRON_EXP_BJBUSINESS, "ItaogaoCrawlerCli", this);
				} else if ("tmtpost".equals(site)) {
					QuartzJobUtils.createQuartzJob(CRON_EXP_1TIME, "ItaogaoCrawlerCli", this);
				} else if ("chinanews".equals(site)) {
					QuartzJobUtils.createQuartzJob(CRON_EXP_4TIMES, "ItaogaoCrawlerCli", this);
				} else if ("huanqiu".equals(site)) {
					QuartzJobUtils.createQuartzJob(CRON_EXP_4TIMES, "ItaogaoCrawlerCli", this);
				} else if ("cjyuanchuang".equals(site)) {
					QuartzJobUtils.createQuartzJob(CRON_EXP_4TIMES, "ItaogaoCrawlerCli", this);
				} else if ("cjmagazine".equals(site)) {
					QuartzJobUtils.createQuartzJob(CRON_EXP_CAIJING, "ItaogaoCrawlerCli", this);
				} else if ("jjrb".equals(site)) {
					QuartzJobUtils.createQuartzJob(CRON_EXP_CECN, "ItaogaoCrawlerCli", this);
				} else if ("ynxxb".equals(site)) {
					QuartzJobUtils.createQuartzJob(CRON_EXP_YNXXB, "ItaogaoCrawlerCli", this);
				} else if ("cnfol".equals(site)) {
					QuartzJobUtils.createQuartzJob(CRON_EXP_4TIMES, "ItaogaoCrawlerCli", this);
				} else if ("guochengxin".equals(site)) {
					QuartzJobUtils.createQuartzJob(CRON_EXP_4TIMES, "ItaogaoCrawlerCli", this);
				} else if ("yinhang123".equals(site)) {
					QuartzJobUtils.createQuartzJob(CRON_EXP_4TIMES, "ItaogaoCrawlerCli", this);
				}
				LOG.info("Finish Create Quartz Job of Itaogao Crawler.");
			} catch (Exception e) {
				e.printStackTrace();
			}
		} else if (cmdLine.hasOption("once")) {
			execute();
		}
	}

	@Override
	public void execute() {
		LOG.info("Execute Itaogao Crawler Cli.");
		long start = System.currentTimeMillis();
		try {
			ProxyUtil.initQueue(true);
			if ("tmtpost".equals(site)) {
				if ("all".equals(type)) {
					TmtpostCrawler crawler = new TmtpostCrawler();
					crawler.startCrawlerAll();
				} else {
					LOG.error("type is not found: " + type);
					return;
				}
			} else if ("jingji21".equals(site)) {
				if ("seed".equals(type)) {
					Jingji21SeedCrawler crawler = new Jingji21SeedCrawler(proxy);
					crawler.crawl();
				} else if ("page".equals(type)) {
					Jingji21PageCrawler crawler = new Jingji21PageCrawler(proxy);
					crawler.crawl();
				} else if ("update".equals(type)) {
					Jingji21UpdateCrawler crawler1 = new Jingji21UpdateCrawler(proxy);
					crawler1.crawl();
					Jingji21PageCrawler crawler2 = new Jingji21PageCrawler(proxy);
					crawler2.crawl();
				} else {
					LOG.error("type is not found: " + type);
					return;
				}
			} else if ("southcn".equals(site)) {
				if ("seed".equals(type)) {
					SouthcnSeedCrawler crawler = new SouthcnSeedCrawler(proxy);
					crawler.crawl();
				} else if ("page".equals(type)) {
					SouthcnPageCrawler crawler = new SouthcnPageCrawler(proxy);
					crawler.crawl();
				} else if ("update".equals(type)) {
					SouthcnUpdateCrawler crawler1 = new SouthcnUpdateCrawler(proxy);
					crawler1.crawl();
					SouthcnPageCrawler crawler2 = new SouthcnPageCrawler(proxy);
					crawler2.crawl();
				} else {
					LOG.error("type is not found: " + type);
					return;
				}
			} else if ("cnstock".equals(site)) {
				if ("seed".equals(type)) {
					CnstockSeedCrawler crawler = new CnstockSeedCrawler(proxy);
					crawler.crawl();
				} else if ("page".equals(type)) {
					CnstockPageCrawler crawler = new CnstockPageCrawler(proxy);
					crawler.crawl();
				} else if ("update".equals(type)) {
					CnstockUpdateCrawler crawler1 = new CnstockUpdateCrawler(proxy);
					crawler1.crawl();
					CnstockPageCrawler crawler2 = new CnstockPageCrawler(proxy);
					crawler2.crawl();
				} else {
					LOG.error("type is not found: " + type);
					return;
				}
			} else if ("infzm".equals(site)) {
				if ("seed".equals(type)) {
					InfzmSeedCrawler crawler = new InfzmSeedCrawler(proxy);
					crawler.crawl();
				} else if ("page".equals(type)) {
					InfzmPageCrawler crawler = new InfzmPageCrawler(proxy);
					crawler.crawl();
				} else if ("update".equals(type)) {
					InfzmUpdateCrawler crawler1 = new InfzmUpdateCrawler(proxy);
					crawler1.crawl();
					InfzmPageCrawler crawler2 = new InfzmPageCrawler(proxy);
					crawler2.crawl();
				} else {
					LOG.error("type is not found: " + type);
					return;
				}
			} else if ("cbcomcn".equals(site)) {
				if ("seed".equals(type)) {
					CbcomcnSeedCrawler crawler = new CbcomcnSeedCrawler(proxy);
					crawler.crawl();
				} else if ("page".equals(type)) {
					CbcomcnPageCrawler crawler = new CbcomcnPageCrawler(proxy);
					crawler.crawl();
				} else if ("update".equals(type)) {
					CbcomcnUpdateCrawler crawler1 = new CbcomcnUpdateCrawler(proxy);
					crawler1.crawl();
					CbcomcnPageCrawler crawler2 = new CbcomcnPageCrawler(proxy);
					crawler2.crawl();
				} else {
					LOG.error("type is not found: " + type);
					return;
				}
			} else if ("oeeee".equals(site)) {
				if ("seed".equals(type)) {
					OeeeeSeedTagCrawler crawler1 = new OeeeeSeedTagCrawler(proxy);
					crawler1.crawl();
					OeeeeSeedCrawler crawler2 = new OeeeeSeedCrawler(proxy);
					crawler2.crawl();
				} else if ("page".equals(type)) {
					OeeeePageCrawler crawler = new OeeeePageCrawler(proxy);
					crawler.crawl();
				} else if ("update".equals(type)) {
					OeeeeUpdateCrawler crawler1 = new OeeeeUpdateCrawler(proxy);
					crawler1.crawl();
					OeeeePageCrawler crawler2 = new OeeeePageCrawler(proxy);
					crawler2.crawl();
				} else {
					LOG.error("type is not found: " + type);
					return;
				}
			} else if ("cscomcn".equals(site)) {
				if ("seed".equals(type)) {
					CscomcnSeedCrawler crawler = new CscomcnSeedCrawler(proxy);
					crawler.crawl();
				} else if ("page".equals(type)) {
					CscomcnPageCrawler crawler = new CscomcnPageCrawler(proxy);
					crawler.crawl();
				} else if ("update".equals(type)) {
					CscomcnUpdateCrawler crawler1 = new CscomcnUpdateCrawler(proxy);
					crawler1.crawl();
				} else {
					LOG.error("type is not found: " + type);
					return;
				}
			} else if ("mrjjxw".equals(site)) {
				MrjjxwCrawler crawler = new MrjjxwCrawler();
				if ("all".equals(type)) {
					crawler.startCrawlerAll();
				} else if ("update".equals(type)) {
					crawler.startCrawlerUpdate();
				}else if ("single".equals(type)) {
					crawler.setTime(time);
					crawler.startCrawlerUpdateOne();
				}
				else {
					LOG.error("type is not found: " + type);
					return;
				}
			} else if ("yicai".equals(site)) {
				NewsBaseCrawler crawler = new YiCaiDetailCrawler();
				crawler.setProxy(proxy);
				if ("all".equals(type)) {
					crawler.startAll();
				} else if ("update".equals(type)) {
					crawler.update();
				} else {
					LOG.error("type is not found: " + type);
					return;
				}
			} else if ("cjyuanchuang".equals(site)) {
				NewsBaseCrawler crawler = new CJYuanChuangDetailCrawler();
				crawler.setProxy(proxy);
				if ("all".equals(type)) {
					crawler.startAll();
				} else if ("update".equals(type)) {
					crawler.update();
				} else {
					LOG.error("type is not found: " + type);
					return;
				}
			} else if ("cjmagazine".equals(site)) {
				NewsBaseCrawler crawler = new CJMagazineDetailCrawler();
				crawler.setProxy(proxy);
				if ("all".equals(type)) {
					crawler.crawl();
				} else if ("update".equals(type)) {
					crawler.update();
				} else {
					LOG.error("type is not found: " + type);
					return;
				}
			} else if ("bjbusiness".equals(site)) {
				NewsBaseCrawler crawler = new BJBusinessDetailCrawler();
				crawler.setProxy(proxy);
				if ("all".equals(type)) {
					crawler.startAll();
				} else if ("update".equals(type)) {
					crawler.update();
				} else {
					LOG.error("type is not found: " + type);
					return;
				}
			} else if ("jjckb".equals(site)) {
				NewsBaseCrawler crawler = new JjckbDetailCrawler();
				crawler.setProxy(proxy);
				if ("all".equals(type)) {
					crawler.startAll();
				} else if ("update".equals(type)) {
					crawler.update();
				} else {
					LOG.error("type is not found: " + type);
					return;
				}
			} else if ("stcn".equals(site)) {
				NewsBaseCrawler crawler = new STCNDetailCrawler();
				crawler.setProxy(proxy);
				if ("all".equals(type)) {
					crawler.crawl();
				} else if ("update".equals(type)) {
					crawler.update();
				} else {
					LOG.error("type is not found: " + type);
					return;
				}
			} else if ("jjrb".equals(site)) {
				NewsBaseCrawler crawler = new JjrbDetailCrawler();
				crawler.setProxy(proxy);
				if ("all".equals(type)) {
					crawler.crawl();
				} else if ("update".equals(type)) {
					crawler.update();
				} else {
					LOG.error("type is not found: " + type);
					return;
				}
			} else if ("ynxxb".equals(site)) {
				NewsBaseCrawler crawler = new YnxxbDetailCrawler();
				crawler.setProxy(proxy);
				if ("all".equals(type)) {
					crawler.crawl();
				} else if ("update".equals(type)) {
					crawler.update();
				} else {
					LOG.error("type is not found: " + type);
					return;
				}
			} else if ("business21".equals(site)) {
				Business21Crawler crawler = new Business21Crawler();
				if ("all".equals(type)) {
					crawler.startCrawler();
				}
			} else if ("gzdialy".equals(site)) {
				if ("seed".equals(type)) {
					GzDailySeedCrawler crawler = new GzDailySeedCrawler(proxy);
					crawler.crawl();
				} else if ("page".equals(type)) {
					GzDailyPageCrawler crawler = new GzDailyPageCrawler(proxy);
					crawler.crawl();
				} else if ("update".equals(type)) {
					GzDailyUpdateCrawler crawler1 = new GzDailyUpdateCrawler(proxy);
					crawler1.crawl();
					GzDailyPageCrawler crawler2 = new GzDailyPageCrawler(proxy);
					crawler2.crawl();
				} else {
					LOG.error("type is not found: " + type);
					return;
				}
			} else if ("ycwb".equals(site)) {
				YangchengEveningNewsCrawler crawler = new YangchengEveningNewsCrawler();
				if ("all".equals(type)) {
					crawler.startCrawlerAll();
				} else if ("update".equals(type)) {
					crawler.startCrawlerUpdate();
				} else if ("single".equals(type)) {
					crawler.setTime(time);
					crawler.startCrawlerUpdateSingle();
				} else {
					LOG.error("type is not found: " + type);
					return;
				}
			} else if ("chinanews".equals(site)) {
				ChinanewsCrawler crawler = new ChinanewsCrawler();
				if ("all".equals(type)) {
					crawler.startCrawlerAll();
				} else if ("update".equals(type)) {
					crawler.startCrawlerUpdate();
				} else {
					LOG.error("type is not found: " + type);
					return;
				}
			} else if ("szsb".equals(site)) {
				NewsBaseCrawler crawler = new SzsbDetailCrawler();
				if ("all".equals(type)) {
					crawler.startAll();
				} else if ("update".equals(type)) {
					crawler.update();
				} else {
					LOG.error("type is not found: " + type);
					return;
				}
			} else if ("ccstock".equals(site)) {
				NewsBaseCrawler crawler = new CcstockDetailCrawler();
				if ("all".equals(type)) {
					crawler.startAll();
				} else if ("update".equals(type)) {
					crawler.update();
				} else {
					LOG.error("type is not found: " + type);
					return;
				}
			} else if ("huanqiu".equals(site)) {
				HuanqiuCrawlerAlternative crawler = new HuanqiuCrawlerAlternative();
				if ("all".equals(type)) {
					crawler.startCrawlerAll();
				} else {
					LOG.error("type is not found: " + type);
					return;
				}
			} else if ("cnfol".equals(site)) {
				if ("seed".equals(type)) {
					CnfolSeedCrawler crawler = new CnfolSeedCrawler(proxy);
					crawler.crawl();
				} else if ("page".equals(type)) {
					CnfolPageCrawler crawler = new CnfolPageCrawler(proxy);
					crawler.crawl();
				} else if ("update".equals(type)) {
					CnfolUpdateCrawler crawler1 = new CnfolUpdateCrawler(proxy);
					crawler1.crawl();
					CnfolPageCrawler crawler2 = new CnfolPageCrawler(proxy);
					crawler2.crawl();
				} else {
					LOG.error("type is not found: " + type);
					return;
				}
			} else if ("guochengxin".equals(site)) {
				if ("seed".equals(type)) {
					GuochengxinSeedCrawler crawler = new GuochengxinSeedCrawler(proxy);
					crawler.crawl();
				} else if ("page".equals(type)) {
					GuochengxinPageCrawler crawler = new GuochengxinPageCrawler(proxy);
					crawler.crawl();
				} else if ("update".equals(type)) {
					GuochengxinUpdateCrawler crawler1 = new GuochengxinUpdateCrawler(proxy);
					crawler1.crawl();
					GuochengxinPageCrawler crawler2 = new GuochengxinPageCrawler(proxy);
					crawler2.crawl();
				} else {
					LOG.error("type is not found: " + type);
					return;
				}
			} else if ("yinhang123".equals(site)) {
				if ("seed".equals(type)) {
					Yinhang123SeedCrawler crawler = new Yinhang123SeedCrawler(proxy);
					crawler.crawl();
				} else if ("page".equals(type)) {
					Yinhang123PageCrawler crawler = new Yinhang123PageCrawler(proxy);
					crawler.crawl();
				} else if ("update".equals(type)) {
					Yinhang123UpdateCrawler crawler1 = new Yinhang123UpdateCrawler(proxy);
					crawler1.crawl();
					Yinhang123PageCrawler crawler2 = new Yinhang123PageCrawler(proxy);
					crawler2.crawl();
				} else {
					LOG.error("type is not found: " + type);
					return;
				}
			} else {
				LOG.error("site is not found: " + site);
				return;
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
		LOG.info("Itaogao Crawler done.");
		LOG.info(String.format("total used time=%s second(s)", (System.currentTimeMillis() - start) / 1000));
	}

	public static void main(String[] args) {
		AdvCli.initRunner(args, "ItaogaoCrawlerCli", new ItaogaoCrawlerCli());
	}
}
